
package javaapplication23;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;

import java.util.ArrayList;
import java.util.Scanner;

import java.io.*;

import Model.Driver;
import View.DriverView;
import Sort.*;

/**
 *
 * @author pol
 */
public class SearchAndSort {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
//        ArrayList<Driver> d = new ArrayList<Driver>();

        // defines the header
        String[] header = {"Name", "Class", "Experience", "Salary"};

        try {
            Scanner in = new Scanner(new FileReader("drivers.data"));
            d = readData(in);
//            BubbleSort.sort(d, new CompareByExperience());
//            InsertionSort.sort(d, new CompareBySalary());
            DriverView dv = new DriverView(d, header);

        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }

    private static Driver[] readData(Scanner in) {
        int n = in.nextInt();
        in.nextLine();

        Driver[] drivers = new Driver[n];
        for (int i = 0; i < n; i++) {
            Driver d = new Driver();
            d.readData(in);
            drivers[i] = d;
        }
        return drivers;
    }
    
    private static Driver[] d;
}
